package com.cennavi.utils;

import com.fasterxml.jackson.databind.ObjectMapper;

import org.apache.log4j.Logger;

import java.util.HashMap;
import java.util.List;

public class JsonUtil {

	private static Logger logger = Logger.getLogger(JsonUtil.class);
	private static final ObjectMapper mapper = new ObjectMapper();


	public static Object toObject(String json, Class ObjectClass) {
		Object object = null;
		if (ObjectClass == null) {
			ObjectClass = HashMap.class;
		}
		if (json == null) {
			return null;
		}
		if (json != null) {
			json = json.replaceAll("\'", "\"");
		}
		try {
			object = mapper.readValue(json, ObjectClass);
		} catch (Exception e) {
			logger.error(e.getMessage());
		}
		return object;
	}




}
